//
//  NSMutableArray+AFNetGet.m
//  FootBallTest
//
//  Created by lanou3g on 15/5/29.
//  Copyright (c) 2015年 lanou3g. All rights reserved.
//

#import "NSMutableArray+AFNetGet.h"
#import "AFHTTPRequestOperationManager.h"
#import "VideoModel.h"
@implementation NSMutableArray (AFNetGet)

+ (void)getMutableArrayWithUrl:(NSString *)url tableView:(UITableView *)tableView success:(void (^)(NSMutableArray * returnArray,NSString *vid))success{
    NSMutableArray *array = [NSMutableArray array];
    
    AFHTTPRequestOperationManager *manager = [AFHTTPRequestOperationManager manager];
    NSDictionary *dict = @{@"format":@"json"};
    __block typeof(array) weakArray = array;
        [manager GET:url parameters:dict success:^(AFHTTPRequestOperation *operation, id responseObject) {
       
            
     
        
        NSArray *dataDictArray= [[responseObject objectForKey:@"result"] objectForKey:@"data"];
        
        for (NSDictionary *littleDict in dataDictArray) {
            
            VideoModel *weakModel = [[VideoModel alloc]init];
            [weakModel setValuesForKeysWithDictionary:littleDict];
         ;
            [weakArray addObject:weakModel];
        }
            VideoModel *model = weakArray.lastObject;
            NSString *vid = model.vid;
            success(weakArray,vid);
        
    } failure:^(AFHTTPRequestOperation *operation, NSError *error) {
        
       
        
    }];
    
    
  
}



@end
